//
//  RNOLUseCouponTopBar.m
//  RongNiuOnline
//
//  Created by apple on 2018/5/21.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLUseCouponTopBar.h"

@interface RNOLUseCouponTopBar()

@property (nonatomic,strong) UIButton *leftButton;
@property (nonatomic,strong) UIButton *rightButton;

@end

@implementation RNOLUseCouponTopBar


- (UIButton *)leftButton{
    if (!_leftButton) {
        _leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_leftButton setTitle:@"不使用优惠" forState:UIControlStateNormal];
        _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [_leftButton setTitleColor:kAppMainColor forState:UIControlStateNormal];
        _leftButton.titleLabel.font = KFontSize(13);
        [_leftButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _leftButton;
}

- (UIButton *)rightButton{
    if (!_rightButton) {
        _rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_rightButton setTitle:@"确定" forState:UIControlStateNormal];
        _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [_rightButton setTitleColor:kAppMainColor forState:UIControlStateNormal];
        _rightButton.titleLabel.font = KFontSize(13);
        [_rightButton addTarget:self action:@selector(confirmAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _rightButton;
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = kBgColor;
        [self setup];
    }
    return self;
}


- (void)setup{
    
    [self addSubview: self.leftButton];
    [self addSubview: self.rightButton];

    
    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.width.equalTo(@70);
        make.height.equalTo(@30);
        make.centerY.equalTo(self.mas_centerY);
    }];
    
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(-15);
        make.width.equalTo(@70);
        make.height.equalTo(@30);
        make.centerY.equalTo(self.mas_centerY);
    }];
}



#pragma mark- 不使用
- (void)closeAction{
    !self.closeBlock? : self.closeBlock();
}

#pragma mark- 确定使用红包或者优惠券
- (void)confirmAction{
    !self.confirmBlock? : self.confirmBlock();
}




@end
